/*
 * Copyright 2010 Mark Slater
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 */

package argo.jdom;

import java.util.List;
import java.util.Map;

/**
 * <p/>
 * Created by IntelliJ IDEA.
 * User: zslajchrt
 * Date: Nov 5, 2010
 * Time: 9:09:50 PM
 */
public class JsonFunctionCallNode extends JsonNode {
    private final List<JsonNode> paramNodes;
    final String functionName;

    public JsonFunctionCallNode(final String functionName, final List<JsonNode> paramNodes) {
        this.paramNodes = paramNodes;
        this.functionName = functionName;
    }

    public boolean hasParameters() {
        return true;
    }

    public List<JsonNode> getParameters() {
        return paramNodes;
    }

    @Override
    public JsonNodeType getType() {
        return JsonNodeType.FUNCTION_CALL;
    }

    public boolean hasText() {
        return true;
    }

    public String getText() {
        return functionName;
    }

    public boolean hasFields() {
        return false;
    }

    public Map<JsonStringNode, JsonNode> getFields() {
        throw new IllegalStateException("Attempt to get fields on a JsonNode without fields.");
    }

    public boolean hasElements() {
        return true;
    }

    public List<JsonNode> getElements() {
        throw new IllegalStateException("Attempt to get elements on a JsonNode without elements.");
    }

    @Override
    public boolean equals(final Object that) {
        if (this == that) return true;
        if (that == null || getClass() != that.getClass()) return false;

        return false;
//        final JsonFunctionCallNode thatJsonTextNode = (JsonFunctionCallNode) that;
//        return this.value.equals(thatJsonTextNode.value);
    }

//    @Override
//    public int hashCode() {
//        return value.hashCode();
//    }

    @Override
    public String toString() {
        return new StringBuilder()
                .append("JsonFunctionCallNode value:[")
//                .append(value)
                .append("]")
                .toString();
    }

}
